<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>regist</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="css/style.css" />
		<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
		<!-- 可选的Bootstrap主题文件（一般不用引入） -->
		<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">
		<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
		<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
		<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
		<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script></span>
	</head>
	<body onLoad="startTime()">
		<div id="wrap">
			<div id="top_content">
					<div id="header">
						<div id="rightheader">
							<p id="time">

								<br />
							</p>
						</div>
						<div id="topheader">
							<h1 id="title">
								<a href="#">华夏医院在线平台</a>
							</h1>
						</div>
						<div id="navigation">
						</div>
					</div>
				<div id="content">
					<p id="whereami">
					</p>
					<h1 style="margin-left: 330px">
						器械注册
					</h1>
					<form action="photos/login.html" method="post">
						<table cellpadding="0" cellspacing="0" border="0"
							class="form_table" style="margin-left:190px">
							<tr>
								<td valign="middle" align="right">
									器械名称:
								</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" class="form-control" placeholder="器械名称" aria-describedby="basic-addon1" v-model="device.name" />
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									规格:
								</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" class="form-control" placeholder="规格" aria-describedby="basic-addon1" v-model="device.telspecification"/>
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									简介:
								</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri"placeholder="简介" v-model="device.directions" />
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									用法:
								</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri"placeholder="用法" v-model="device.useage" />
								</td>
							</tr>

							<img id="num" :src="url" style="position:absolute;left:900px;top: 350px;height:40px"/>
							<tr>
								<td valign="middle" align="right">
									验证码:
									<a href="javascript:;" @click="getImg">换一张</a>

								</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" v-model="code" />
								</td>
							</tr>
						</table>
						<p>
							<input type="button" @click="register" class="btn btn-default" value="注册 "style="margin-left:350px;width:55px" id="btn" />
						</p>
					</form>
				</div>
			</div>
			<div id="footer">
				<div id="footer_bg">
					Copyright © 小凡哥 All rights reserved.
					li123fan00@foxmail.com
				</div>
			</div>
		</div>
	</body>
</html>
<script src="/es_healthy/js/vue.js"></script>
<script src="/es_healthy/js/axios.min.js"></script>

<script>
	function startTime()
	{
		var today=new Date();//定义日期对象
		var yyyy = today.getFullYear();//通过日期对象的getFullYear()方法返回年
		var MM = today.getMonth()+1;//通过日期对象的getMonth()方法返回年
		var dd = today.getDate();//通过日期对象的getDate()方法返回年
		var hh=today.getHours();//通过日期对象的getHours方法返回小时
		var mm=today.getMinutes();//通过日期对象的getMinutes方法返回分钟
		var ss=today.getSeconds();//通过日期对象的getSeconds方法返回秒
		// 如果分钟或小时的值小于10，则在其值前加0，比如如果时间是下午3点20分9秒的话，则显示15：20：09
		MM=checkTime(MM);
		dd=checkTime(dd);
		mm=checkTime(mm);
		ss=checkTime(ss);
		var day; //用于保存星期（getDay()方法得到星期编号）
		if(today.getDay()==0)   day   =   "星期日 "
		if(today.getDay()==1)   day   =   "星期一 "
		if(today.getDay()==2)   day   =   "星期二 "
		if(today.getDay()==3)   day   =   "星期三 "
		if(today.getDay()==4)   day   =   "星期四 "
		if(today.getDay()==5)   day   =   "星期五 "
		if(today.getDay()==6)   day   =   "星期六 "
		document.getElementById('time').innerHTML=yyyy+"-"+MM +"-"+ dd +" " + hh+":"+mm+":"+ss+"   " + day;
		setTimeout('startTime()',1000);//每一秒中重新加载startTime()方法
	}

	function checkTime(i)
	{
		if (i<10){
			i="0" + i;
		}
		return i;
	}

</script>

<script>
	var app=new Vue({
		el:"#wrap",
		data:{
			url:"",
			device:{
			},
			code:"",

		},
		methods:{
			age(orginnumber){
				var myDate = new Date();
				var month = myDate.getMonth() + 1;
				var day = myDate.getDate();
				var age = myDate.getFullYear() - orginnumber.substring(6, 10) - 1;
				if (orginnumber.substring(10, 12) < month || orginnumber.substring(10, 12) == month && orginnumber.substring(12, 14) <= day) {
					age++;
				}
				console.log(age);
				this.doctor.age=age;
			},
			getImg(){
				this.getSrc();
			},
			//获取验证码
			getSrc(){
				var _this = this;
				axios.get("http://localhost:8080/es_healthy/user/getImage?time="+Math.random()).then(res=>{
					console.log(res.data);
					_this.url = res.data;
				})
			},


			//注册用户信息
			register() {
					var role=sessionStorage.getItem("role");
					if(role=="admin"){
						axios.post("http://localhost:8080/es_healthy/admin/registerDevice?code="+this.code+"&token="+sessionStorage.getItem("token"),this.device).then(res=>{
							// alert(res.data.message);
							if(res.data.state)
							{
								alert(res.data.msg+",点击确定");
								// location.href="/es_healthy/login.html";
								window.history.go(-1);
							}else
							{
								alert(res.data.msg);
							}

						});

					}else{
						alert("请登录");
						location.href="/es_healthy/loginAdmin.html";
					}


			}


		},
		created(){
			this.getSrc();
		}
	})
</script>